package com.dqhl.businessapp.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.dqhl.businessapp.R;

/**
 * Created by mac on 16/11/24.
 * CustomProgressDialog
 */
public class CustomProgressDialog extends Dialog {

    private Context context;
    private String content;
    private TextView tv_loading_content;

    public CustomProgressDialog(Context context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    public CustomProgressDialog(Activity context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    public CustomProgressDialog(Activity context, String content) {
        super(context, R.style.CustomDialog);
        this.context = context;
        this.content = content;
    }

    public CustomProgressDialog(Context context, String content) {
        super(context, R.style.CustomDialog);
        this.context = context;
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setCanceledOnTouchOutside(false);
        super.onCreate(savedInstanceState);

        initView();
    }

    private void initView() {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.dialog_progress_custom, null);
        setContentView(view);

        tv_loading_content = (TextView) view.findViewById(R.id.tv_loading_content);
        if (!TextUtils.isEmpty(content)) {
            tv_loading_content.setText(content);
        }
    }

    /**
     * 设置内容
     *
     * @param string
     */
    public void setContent(String string) {
        tv_loading_content.setText(string);
    }
}
